package com.lanjiu.lib.imclient.dto;

import com.lanjiu.pro.business.BusinessProtocolEntities;
import com.lanjiu.lib.imclient.dto.base.Dto;
import com.lanjiu.lib.imclient.dto.chat.FileDto;
import com.lanjiu.lib.imclient.dto.chat.PictureDto;
import com.lanjiu.lib.imclient.dto.chat.TextDto;
import com.lanjiu.lib.imclient.dto.chat.VideoDto;
import com.lanjiu.lib.imclient.dto.chat.VoiceDto;
import com.lanjiu.lib.imclient.ims.IMSContacts;

/**
 * @description:
 * @author: Panwei
 * @date: 2019/12/4 19:41
 */
public class OffMsgDto extends Dto {

    // 消息ID
    private String msgId;

    // 消息内容类型(图片/视频/文本/语音/文件)
    private int chatType;

    // 文本实体
    private TextDto text;

    // 图片实体
    private PictureDto picture;

    // 视频实体
    private VideoDto video;

    // 语音实体
    private VoiceDto voice;

    // 文件实体
    private FileDto file;

    // 消息发送者用户ID
    private String fromId;

    // 消息发送时间
    private String msgTime;

    // 好友实体
    private FriendDto mFriendDto;

    public OffMsgDto() {
    }

    public String getMsgId() {
        return msgId;
    }

    public void setMsgId(String msgId) {
        this.msgId = msgId;
    }

    public int getChatType() {
        return chatType;
    }

    public void setChatType(int chatType) {
        this.chatType = chatType;
    }

    public TextDto getText() {
        return text;
    }

    public void setText(TextDto text) {
        this.text = text;
    }

    public PictureDto getPicture() {
        return picture;
    }

    public void setPicture(PictureDto picture) {
        this.picture = picture;
    }

    public VideoDto getVideo() {
        return video;
    }

    public void setVideo(VideoDto video) {
        this.video = video;
    }

    public VoiceDto getVoice() {
        return voice;
    }

    public void setVoice(VoiceDto voice) {
        this.voice = voice;
    }

    public FileDto getFile() {
        return file;
    }

    public void setFile(FileDto file) {
        this.file = file;
    }

    public String getFromId() {
        return fromId;
    }

    public void setFromId(String fromId) {
        this.fromId = fromId;
    }

    public String getMsgTime() {
        return msgTime;
    }

    public void setMsgTime(String msgTime) {
        this.msgTime = msgTime;
    }

    public FriendDto getmFriendDto() {
        return mFriendDto;
    }

    public void setmFriendDto(FriendDto mFriendDto) {
        this.mFriendDto = mFriendDto;
    }

    public OffMsgDto(BusinessProtocolEntities.TouristFriendOffMessage offMessage, String path) {
        this.msgId = offMessage.getMsgId();
        this.chatType = offMessage.getChatType();
        if (chatType == IMSContacts.MsgContentType.TEXT
                || chatType == IMSContacts.MsgContentType.APPLY_TOURISTS
                || chatType == IMSContacts.MsgContentType.APPLY_REGISTERED
                || chatType == IMSContacts.MsgContentType.APPLY_REFUSE_TOURISTS
                || chatType == IMSContacts.MsgContentType.APPLY_REFUSE_REGISTERED
                || chatType == IMSContacts.MsgContentType.INVITE_REFUSE_TOURISTS
                || chatType == IMSContacts.MsgContentType.INVITE_REFUSE_REGISTERED
                || chatType == IMSContacts.MsgContentType.INVITE_TOURISTS
                || chatType == IMSContacts.MsgContentType.INVITE_REGISTERED
                || chatType == IMSContacts.MsgContentType.APPLY_FRIEND_TOURISTS
                || chatType == IMSContacts.MsgContentType.APPLY_FRIEND_REGISTERED
                || chatType == IMSContacts.MsgContentType.APPLY_REFUSE_FRIEND_TOURISTS
                || chatType == IMSContacts.MsgContentType.APPLY_REFUSE_FRIEND_REGISTERED)
            this.text = new TextDto(offMessage.getText());
        else if (chatType == IMSContacts.MsgContentType.PICTURE)
            this.picture = new PictureDto(offMessage.getPicture(), path);
        else if (chatType == IMSContacts.MsgContentType.VIDEO)
            this.video = new VideoDto(offMessage.getVideo(), path);
        else if (chatType == IMSContacts.MsgContentType.VOICE)
            this.voice = new VoiceDto(offMessage.getVoice(), path);
        else if (chatType == IMSContacts.MsgContentType.FILE)
            this.file = new FileDto(offMessage.getFile());
        this.fromId = offMessage.getMsgFromUserId();
        this.msgTime = offMessage.getMsgTime();
        this.mFriendDto = new FriendDto(offMessage.getTouristsFriend());
    }

    public OffMsgDto(BusinessProtocolEntities.RegistFriendOffMessage offMessage, String path) {
        this.msgId = offMessage.getMsgId();
        this.chatType = offMessage.getChatType();
        if (chatType == IMSContacts.MsgContentType.TEXT
                || chatType == IMSContacts.MsgContentType.APPLY_TOURISTS
                || chatType == IMSContacts.MsgContentType.APPLY_REGISTERED
                || chatType == IMSContacts.MsgContentType.APPLY_REFUSE_TOURISTS
                || chatType == IMSContacts.MsgContentType.APPLY_REFUSE_REGISTERED
                || chatType == IMSContacts.MsgContentType.INVITE_REFUSE_TOURISTS
                || chatType == IMSContacts.MsgContentType.INVITE_REFUSE_REGISTERED
                || chatType == IMSContacts.MsgContentType.INVITE_TOURISTS
                || chatType == IMSContacts.MsgContentType.INVITE_REGISTERED
                || chatType == IMSContacts.MsgContentType.APPLY_FRIEND_TOURISTS
                || chatType == IMSContacts.MsgContentType.APPLY_FRIEND_REGISTERED
                || chatType == IMSContacts.MsgContentType.APPLY_REFUSE_FRIEND_TOURISTS
                || chatType == IMSContacts.MsgContentType.APPLY_REFUSE_FRIEND_REGISTERED)
            this.text = new TextDto(offMessage.getText());
        else if (chatType == IMSContacts.MsgContentType.PICTURE)
            this.picture = new PictureDto(offMessage.getPicture(), path);
        else if (chatType == IMSContacts.MsgContentType.VIDEO)
            this.video = new VideoDto(offMessage.getVideo(), path);
        else if (chatType == IMSContacts.MsgContentType.VOICE)
            this.voice = new VoiceDto(offMessage.getVoice(), path);
        else if (chatType == IMSContacts.MsgContentType.FILE)
            this.file = new FileDto(offMessage.getFile());
        this.fromId = offMessage.getMsgFromUserId();
        this.msgTime = offMessage.getMsgTime();
        this.mFriendDto = new FriendDto(offMessage.getRegisteredFriend());
    }



    @Deprecated
    @Override
    public Object toProtobuf() {
        return null;
    }
}
